﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Bill;
using OpenSoftStore.BusinessLogic.Member;
using OpenSoftStore.Client.Common;

namespace OpenSoftStore.Client.UIL.ManageReport
{
    public partial class ReportMemberActivity : UserControl
    {
       
        private MemberLogic LgcMember;
        private static ReportMemberActivity instance;
        public static ReportMemberActivity Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ReportMemberActivity();
                }
                return instance;
            }
        }
        public ReportMemberActivity()
        {
            LgcMember = new MemberLogic();
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            dgvMemberAdd.AutoGenerateColumns = false;
            btnSearch_Click(null, null);
            SPACommon.SetDataGridStyle(dgvMemberAdd);
            SPACommon.ShowSummary(dgvMemberAdd);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            DateTime from = dtpFrom.Value.Date;
            DateTime to = dtpTo.Value.Date.AddDays(1).AddSeconds(-1.0);
            var name = txt_name.Text;
            string where =
                 string.Format(" and (a.Name like '%{0}%' or a.CardId like '%{0}%' or a.TelNum like '%{0}%') ",name);
            dgvMemberAdd.DataSource = LgcMember.GetMemberActivityDataTable(from, to,where);
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            SPACommon.ExportToExcel(dgvMemberAdd, "近期没消费客户统计");
        }
    }
}
